package com.yuju.init.fastdfs;

import org.csource.fastdfs.ClientGlobal;
import org.csource.fastdfs.StorageClient;
import org.csource.fastdfs.StorageClient1;
import org.csource.fastdfs.StorageServer;
import org.csource.fastdfs.TrackerClient;
import org.csource.fastdfs.TrackerServer;
import org.springframework.core.io.ClassPathResource;

import com.yuju.util.ConfigUtils;

/**
 * 
 * 类名：FastDFSInit  <br />
 *
 * 功能：初始化FastDFS
 *
 * @author : xuehj <br />
 * @Date : 2018年1月5日 下午7:35:06  <br />
 * @version : 1.1 <br />
 */
public class FastDFSInit {
	private static StorageServer storageServer;
	private static StorageClient1 storageClient1;
	private static TrackerServer trackerServer;
	private static TrackerClient trackerClient;
	private static StorageClient storageClient;
	
	public static void init(String filter) {
		ClassPathResource resource = new ClassPathResource("resource/resource-" + filter + ".properties");
		try {
			ConfigUtils redisConfigUtils = ConfigUtils.getInstance(filter);
			
			ClientGlobal.init("resource/resource-" + filter + ".properties");
			
			trackerClient = new TrackerClient();
			trackerServer = trackerClient.getConnection();
			
			storageClient1 = new StorageClient1(trackerServer, null);
			
			storageClient = new StorageClient(trackerServer, storageServer); 
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static StorageServer getStorageServer() {
		return storageServer;
	}

	public static void setStorageServer(StorageServer storageServer) {
		FastDFSInit.storageServer = storageServer;
	}

	public static StorageClient1 getStorageClient1() {
		return storageClient1;
	}

	public static void setStorageClient1(StorageClient1 storageClient1) {
		FastDFSInit.storageClient1 = storageClient1;
	}

	public static TrackerServer getTrackerServer() {
		return trackerServer;
	}

	public static void setTrackerServer(TrackerServer trackerServer) {
		FastDFSInit.trackerServer = trackerServer;
	}

	public static TrackerClient getTrackerClient() {
		return trackerClient;
	}

	public static void setTrackerClient(TrackerClient trackerClient) {
		FastDFSInit.trackerClient = trackerClient;
	}

	public static StorageClient getStorageClient() {
		return storageClient;
	}
}
